package com.cc.blog.admin.controller;

import com.cc.blog.admin.domain.dto.DeleteCommentReqDTO;
import com.cc.blog.admin.domain.dto.ExamineCommentReqDTO;
import com.cc.blog.admin.domain.dto.FindCommentPageListReqDTO;
import com.cc.blog.admin.service.AdminCommentService;
import com.cc.blog.common.annotation.ApiOperationLog;
import com.cc.blog.common.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author cc
 */
@RestController
@RequestMapping("/admin/comment")
@Api(tags = "Admin 评论模块")
public class AdminCommentController {

    @Autowired
    private AdminCommentService commentService;

    @PostMapping("/list")
    @ApiOperation(value = "查询评论分页数据")
    @ApiOperationLog(description = "查询评论分页数据")
    public Result findCommentPageList(@RequestBody @Validated FindCommentPageListReqDTO findCommentPageListReqDTO) {
        return commentService.findCommentPageList(findCommentPageListReqDTO);
    }

    @PostMapping("/delete")
    @ApiOperation(value = "评论删除")
    @ApiOperationLog(description = "评论删除")
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    public Result deleteComment(@RequestBody @Validated DeleteCommentReqDTO deleteCommentReqDTO) {
        return commentService.deleteComment(deleteCommentReqDTO);
    }

    @PostMapping("/examine")
    @ApiOperation(value = "评论审核")
    @ApiOperationLog(description = "评论审核")
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    public Result examinePass(@RequestBody @Validated ExamineCommentReqDTO examineCommentReqDTO) {
        return commentService.examine(examineCommentReqDTO);
    }

}